home *** CD-ROM | disk | FTP | other *** search
- Subject: Re: starting out
- Sent: 3/14/96 2:58 PM
- Received: 3/14/96 2:11 PM
- From: Mark Lanett, mlanett@meer.net
- Reply-To: ODF-Interest@CILabs.ORG
- To: OpenDoc Development Framework Discussion List, ODF-Interest@CILabs.
-
- beale@q.continuum.net (Jim Beale) writes:
- >If I create a .idl file, how do I compile it?
- >
- >Do I absolutely need MPW?
-
- The short answer is that you use somc to compile it, and yes you need MPW
- or ToolServer.
-
- I assume you're creating the idl file for an extension. You don't need to
- do this to write a part, since ODF handles it for you. There have been a
- number of discussions recently about extensions, including our imperfect
- support for them in ODF d11, and the misleading or wrong recipes for using
- them. I think we have an archive of this mailing list in case you missed
- them.
-
- But lets just talk about compiling the idl file right now.
-
- Table of Contents
- 1) What exactly does it mean to compile an idl file?
- 2) What tools do you need
- 3) How do you install the tools
- 4) How do you compile
- 5) Common Problems
- 6) The Future
-
-
-
- 1) What exactly does it mean to compile an idl file?
-
- An idl file describes your API in a language-neutral manner. It allows your
- code to be called from any language, using any compiler. Three files are
- needed to accomplish this: .xih, .xh and .cpp.
-
- The .xih file contains tables and other meta-data which will be compiled
- into your part, and read by SOM. These tables describe your stub routines
- in the .cpp file (below). The .xih file contains one structure, called
- (MODULE)(PART)ClassInfo, which you need to export from your shared library.
-
- The .xh file contains inline C++ classes which will enable other C++-based
- parts to call your part. This inline code contains methods for each of the
- routines in your IDL file and calls SOM for each one of them, which in turn
- calls your code. Going through SOM allows it to translate between calling
- conventions of different compilers and languages, and also to transparently
- make the function call across a network.
-
- The .cpp file contains the stub routines which SOM calls. You implement
- your code either directly in these stubs, or call other code written in
- something more convenient, like C++ (this is what ODF does). The .cpp file
- #includes the .xih file, which is how the meta-data gets into your part.
-
- 2) These are the things you need:
- MPW (which you can get from the CodeWarrior CD) or ToolServer
- The OpenDoc DR4 CD.
-
-
-
- 3) And this is what you'll need to do:
- 3.1) Install MPW
- 3.2) Install SOM into MPW
- 3.3) Install ODF into MPW
- 3.4) Configure MPW
- 3.5) Fix one of the ODF build files
-
- 3.1) The CW8 installer will install MPW for you, so you should do that
- first. CW8 also comes with ToolServer, but its an old version and people
- have reported problems with it. Also, they only have a small file
- describing how to set it up. It's easier for now to go with MPW.
-
- Once you've installed MPW, launch it, and insert the DR4 CD.
-
- 3.2) Open this folder:
- Development:CFM-68K and SOMobject:SOMobjectsX for Mac OS:MPW Additions:
-
- Each of these folders needs to be copied into your MPW folder. Don't
- replace anything,
- just add the contents. That is:
- Add the files in CIncludes (in Interfaces) to MPW's CIncludes folder. There
- are 15.
- Add the SOMIncludes folder to MPW's Interfaces folder.
- Add the one file (somlib) in SharedLibraries (in Libraries) to MPW's
- SharedLibraries folder.
- Add the somc file (in Scripts) to MPW's Scripts folder.
- Add the 4 tools in Tools to MPW's Tools folder. The Finder will ask you if
- you want to replace PPCLink; replace it.
- Add the UserStartup*somc file to the MPW folder itself.
-
- 3.3) Open this folder:
- OpenDoc Development Framework : ODFDev : MPW/ToolServer Additions
- Copy the UserStartup*ODF file into your MPW folder.
-
- 3.4) Launch MPW
-
- MPW will ask you where the ODF folder is. Navigate to your ODF folder (in
- your ODFDev folder) and press "Directory".
-
- MPW will also ask where the OpenDocSDK is. Navigate to your OpenDoc Headers
- (in CodeWarrior : MacOS Support : Headers) and click "Directory".
-
- 3.5) Fix one of the ODF build files
-
- When we shipped ODF d11, nobody was compiling their own .idl files. We had
- commented out the rules which built the .cpp stubs file. Type this in MPW:
- Open "{FWToolsDir}"MacMake.rul
- Now do a find on "HLX". You will see 12 lines which have # signs in front
- of them. Remove the #s from lines *except* the first one (with the HLX).
- Save this file and close it.
-
-
-
- 4) Compiling
-
- ODF has default rules for compiling idl files. You will need to add the
- file to your part's makefile and run FWBuild.
-
- 4.1) Add the file to your makefile
- When you generated your part with PartMaker, it created the CodeWarrior
- project and an MPW makefile, called MacMake.bmk. The makefile lists all the
- output of the idl files, like so:
-
- __ComponentSourcesFromIDL = ∂
- "{_FWTargetDir}SOMPart.cpp" d
- "{_FWTargetDir}SOMPart.xh" d
- "{_FWTargetDir}SOMPart.xih"
-
- __ComponentObjects = ∂
- "{_FWObjDir}"SOMPart.cpp.o d
- ...
-
- You don't like the .idl file in the makefile, you list the output files.
- The Make tool will determine how to build those output files based on our
- default rules.
-
- If your idl file was called MyInterface.idl, you will add the output files
- do those definitions like this:
-
- __ComponentSourcesFromIDL = ∂
- "{_FWTargetDir}MyInterface.cpp" d
- "{_FWTargetDir}MyInterface.xih" d
- "{_FWTargetDir}MyInterface.xh" d
- "{_FWTargetDir}SOMPart.cpp" d
- "{_FWTargetDir}SOMPart.xh" d
- "{_FWTargetDir}SOMPart.xih"
-
- __ComponentObjects = ∂
- "{_FWObjDir}"SOMPart.cpp.o d
- ...
-
- The "d"s at the end of the lines need to be typed as option-d.
-
- You also need to add dependency rules, like this:
-
- "{_FWTargetDir}MyInterface.xih" ƒ "{_FWTargetDir}MyInterface.idl"
-
- "{_FWTargetDir}MyInterface.xh" ƒ "{_FWTargetDir}MyInterface.idl"
-
- "{_FWTargetDir}MyInterface.cpp" ƒ "{_FWTargetDir}MyInterface.idl" d
- "{_FWTargetDir}MyInterface.xh" d
- "{_FWTargetDir}MyInterface.xih"
-
- 4.2) Run FWBuild
-
- You are finally ready to build. In the MPW Worksheet, type this:
- (substitute MyPart with your part's folder's name)
- FWBuild -Metrowerks "{ODFDev}MyPart:Sources:MyPart.SOM"
-
- You must have your part's folder in the same folder as ODF for this to work.
-
- FWBuild will run somc to output your .cpp, .xh, and .xih files. At this
- point you can implement your extension. If you change your .idl file, you
- need to do this step over again (but only this step). When the SOM compiler
- writes your .cpp file it will *not* delete anything, so you don't need to
- worry about saving code. It rewrites, not replaces, the .cpp file.
-
-
-
- 5) Common Problems
-
- You may get "include file not found" errors. This would mean that you are
- trying to #include other .idl files which are not found in the standard
- OpendDoc or ODF set. You will need to add the locations of those other .idl
- files to the makefile. For example, if you were building Cyberdog parts you
- would probably have put the PublicIncludes folder in your CodeWarrior
- folder, and would need to change the include listing like this:
-
- __IDLIncludeDirs = d
- -I "HD:CodeWarrior:MacOS Support:Headers:PublicIncludes:" d
- -I "{FWODIDLIncludes}"
-
-
-
- 6) The Future
-
- Clearly this process is extremely cumbersome. There are projects underway
- to convert SOM into a codewarrior plugin. ToolServer will still be required
- for moment, but you won't have to muck with the makefile or FWBuild; you'll
- be able to add the .idl file to your project window and treat it mostly
- like any other source file.
-
- Also, the cross-platform resource compiler (ODFRC) will be a fully native
- CW plugin tool for our next release. Now that ODF has view resources,
- you'll be using it a lot more.
-
-
- --
- Mark Lanett <mlanett@meer.net>
- Have a bajillion brilliant Jobsian lithium licks
-
-